package m.toolkit.rrd4j;
import java.util.List;

import m.framework.template.TemplateUtil;
import m.framework.utils.StrBuilder;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author ming
 * @date 2014年2月24日下午12:47:24
 */
public class RrdUtil {
	private static Logger log = LoggerFactory.getLogger(RrdUtil.class);
	
	public static String create(Create create){
		return TemplateUtil.parseTemplate("/rrd/create.vm", create);
	}
	
	/**
	 * @param time 1970到现在的秒
	 * */
	public static String update(String fileName,Long time,List<String> data){
		StrBuilder sb=new StrBuilder("rrdtool update "+fileName+".rrd ");
		if(time==null){
			sb.append("N");
		}else{
			sb.append(time+"");
		}
		for(String s:data){
			sb.append(":"+s);
		}
		return sb.toString();
	}
	
	
	public static String graph(Graph graph){
		return TemplateUtil.parseTemplate("/rrd/graph.vm", graph);
	}
}




